package com.liu.controller;

import com.liu.domain.vate;
import com.liu.repository.VateRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by liu on 17-9-22.
 */
public class VateController {
    private final static Logger logger = LoggerFactory.getLogger(VateController.class);

    @Autowired
    private VateRepository vateRepository;

    /*
    查询所有列表
     */
    @GetMapping(value = "/vate")
    public List<vate> vateList(){
        System.out.println("vateList");

        logger.info("vateList");

        return vateRepository.findAll();

    }
    /*
    添加
     */
    @PostMapping(value = "/vate")
    public vate vateAdd(vate vate) {


        return vateRepository.save(vate);
    }

    /*
    更新一个
     */
    @PutMapping(value = "/vate/{id}")
    public vate vateUpdate(@PathVariable("id-") Integer id, vate vate) {

        return vateRepository.save(vate);
    }
    /*
    删除一个
     */

    @DeleteMapping(value = "/vate/{id}")
    public void buildDelete(@PathVariable("id") Integer id){
        vateRepository.delete(id);
    }


}
